using System;
using System.Data;
using System.Configuration;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Beta_fundies_controls_Quotes_QuoteList : Controls.DataManagerQuoteControl
{
    protected override void ItemChanged()
    {
        // nonesuch
    }

    public void SetDataSource(List<DAL.Quote> quotes)
    {
        if (quotes != null && quotes.Count > 0)
        {
            mviewQuotes.SetActiveView(viewQuotes);
            gridQuotes.DataSource = quotes;
            gridQuotes.DataBind();
        }
        else
        {
            mviewQuotes.SetActiveView(viewError);
        }
    }

    private bool userRetrieved = false;

    private DAL.User _CurrentUser;
    private DAL.User CurrentUser
    {
        get
        {
            if (userRetrieved == false)
            {
                _CurrentUser = Managers.UserLoginManager.CurrentUser;
                userRetrieved = true;
            }
            return _CurrentUser;
        }
    }

    protected string GetNavigateUrl(long quoteID, int number)
    {
        //return string.Format("~/fundies/vote.aspx?q={0}&vote={1}", quoteID, number);
        return string.Format("javascript:castvote({0}, {1});", quoteID, number);
    }

    protected bool ShowModView()
    {
        return CurrentUser != null && CurrentUser.HasPermissions(DAL.User.UserStatus.Moderator);
    }
}
